package com.ly.heart.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ly.common.utils.DateUtils;
import com.ly.common.utils.SecurityUtils;
import com.ly.common.utils.erp.SnowflakeIdWorker;
import com.ly.heart.mapper.MealRecordMapper;
import com.ly.heart.service.IMealRecordService;
import org.springframework.stereotype.Service;
import com.ly.heart.domain.MealRecordEntity;

import javax.annotation.Resource;

/**
 * 报餐申请记录Service业务层处理
 *
 * @author cxl
 * @date 2024-06-13
 */
@Service
public class MealRecordServiceImpl extends ServiceImpl<MealRecordMapper,MealRecordEntity> implements IMealRecordService {

    @Resource
    private MealRecordMapper mealRecordMapper;

    /**
     * 查询报餐申请记录
     *
     * @param id 报餐申请记录ID
     * @return 报餐申请记录
     */
    @Override
    public MealRecordEntity selectMealRecordEntityById(String id)
    {
        return mealRecordMapper.selectMealRecordEntityById(id);
    }

    /**
     * 查询报餐申请记录列表
     *
     * @param mealRecordEntity 报餐申请记录
     * @return 报餐申请记录
     */
    @Override
    public List<MealRecordEntity> selectMealRecordEntityList(MealRecordEntity mealRecordEntity)
    {
        return mealRecordMapper.selectMealRecordEntityList(mealRecordEntity);
    }

    /**
     * 新增报餐申请记录
     *
     * @param mealRecordEntity 报餐申请记录
     * @return 结果
     */
    @Override
    public int insertMealRecordEntity(MealRecordEntity mealRecordEntity)
    {
        mealRecordEntity.setId(SnowflakeIdWorker.getInstance().nextStringId());
        mealRecordEntity.setUserId(SecurityUtils.getLoginUser().getUser().getUserId());
        mealRecordEntity.setCreateTime(DateUtils.getNowDate());
        return mealRecordMapper.insertMealRecordEntity(mealRecordEntity);
    }

    /**
     * 修改报餐申请记录
     *
     * @param mealRecordEntity 报餐申请记录
     * @return 结果
     */
    @Override
    public int updateMealRecordEntity(MealRecordEntity mealRecordEntity)
    {
        mealRecordEntity.setChangeTime(DateUtils.getNowDate());
        return mealRecordMapper.updateMealRecordEntity(mealRecordEntity);
    }

    /**
     * 批量删除报餐申请记录
     *
     * @param ids 需要删除的报餐申请记录ID
     * @return 结果
     */
    @Override
    public int deleteMealRecordEntityByIds(String[] ids)
    {
        return mealRecordMapper.deleteMealRecordEntityByIds(ids);
    }

    /**
     * 删除报餐申请记录信息
     *
     * @param id 报餐申请记录ID
     * @return 结果
     */
    @Override
    public int deleteMealRecordEntityById(String id)
    {
        return mealRecordMapper.deleteMealRecordEntityById(id);
    }
}
